/**
 * 
 */
package com.p2p.front.dal.dao;

import java.util.List;

import org.apache.ibatis.annotations.Update;

import com.p2p.base.dao.BaseMapper;
import com.p2p.front.dal.model.LoanVariation;


/**
 * @author ruiqi
 *
 */
public interface LoanVariationDao extends BaseMapper{
	String columnNames= "LOAN_ID,AMOUNT,REMAIN_AMOUNT,RETURN_AMOUNT,REPAY_NUM,TENDER_AMOUNT,FLOW_AMOUNT,REPO_AMOUNT,FLOW_DATE,STATUS,TENDER_COUNT,TENDER_BEGIN,TENDER_END,EXPIRED_TIME,UPDATE_TIME,TOTAL_INTEREST";

	void create(LoanVariation LoanVariation);
	
	
	int update(LoanVariation LoanVariation);
	
	@Update("update p2p_loan_variation set STATUS= #{status} where LOAN_ID=#{loanId} and STATUS=#{oldStatus}")
	int updateStatus(LoanVariation LoanVariation);
	
	
	@Update("update p2p_loan_variation set STATUS = 32,TENDER_END = NOW(),TOTAL_INTEREST=#{totalInterest.cent} where LOAN_ID=#{loanId}")
	int updateStatusFroFullTender(LoanVariation LoanVariation);
	
	@Update("update p2p_loan_variation set TENDER_AMOUNT = #{tenderAmount.cent} and TENDER_COUNT= #{tenderCount} where LOAN_ID=#{loanId}")
	int updateTenderAmount(LoanVariation LoanVariation);
	
	public LoanVariation getByLoanId(Long loanId);
	
	public List<LoanVariation> findByLoanIds(List<Long> loanIds);
	
	public LoanVariation getByLoanIdForLock(Long loanId);
	
	public List<LoanVariation> findByStatus(List<Integer> status);
	
}
